
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('eyeData produces correct results liang_g1', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results liang_g1')
    result <- sampler(100000, vy, mX, prior='liang_g1', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.004290000000000000,0.006320000000000000,0.002080000000000000,
0.002330000000000000,0.003490000000000000,0.004490000000000000,
0.002020000000000000,0.004680000000000000,0.002330000000000000,
0.002650000000000000,0.063049999999999995,0.003870000000000000,
0.003610000000000000,0.002280000000000000,0.002030000000000000,
0.003880000000000000,0.001820000000000000,0.002030000000000000,
0.003440000000000000,0.001780000000000000,0.001980000000000000,
0.002200000000000000,0.002500000000000000,0.001860000000000000,
0.001810000000000000,0.004470000000000000,0.001990000000000000,
0.011979999999999999,0.001800000000000000,0.004710000000000000,
0.005240000000000000,0.001840000000000000,0.003270000000000000,
0.002290000000000000,0.002170000000000000,0.007300000000000000,
0.002080000000000000,0.003110000000000000,0.002110000000000000,
0.002000000000000000,0.002090000000000000,0.041799999999999997,
0.002240000000000000,0.002130000000000000,0.001790000000000000,
0.002530000000000000,0.002030000000000000,0.002100000000000000,
0.002930000000000000,0.008290000000000000,0.002420000000000000,
0.004300000000000000,0.002020000000000000,0.013559999999999999,
0.011639999999999999,0.001590000000000000,0.002270000000000000,
0.002750000000000000,0.003400000000000000,0.011590000000000000,
0.001990000000000000,0.034369999999999998,0.002920000000000000,
0.002860000000000000,0.002710000000000000,0.009639999999999999,
0.002300000000000000,0.002120000000000000,0.001990000000000000,
0.002620000000000000,0.017639999999999999,0.001960000000000000,
0.002110000000000000,0.002650000000000000,0.002170000000000000,
0.023130000000000001,0.002390000000000000,0.003600000000000000,
0.001770000000000000,0.002360000000000000,0.001840000000000000,
0.001930000000000000,0.002170000000000000,0.002380000000000000,
0.005350000000000000,0.002410000000000000,0.189319999999999988,
0.002410000000000000,0.003110000000000000,0.025520000000000001,
0.001790000000000000,0.006450000000000000,0.003520000000000000,
0.001750000000000000,0.002070000000000000,0.005220000000000000,
0.002200000000000000,0.001750000000000000,0.015490000000000000,
0.002540000000000000,0.002940000000000000,0.011870000000000000,
0.001620000000000000,0.003990000000000000,0.002030000000000000,
0.002380000000000000,0.004450000000000000,0.004980000000000000,
0.024299999999999999,0.010279999999999999,0.004890000000000000,
0.017850000000000001,0.004900000000000000,0.002460000000000000,
0.002130000000000000,0.002020000000000000,0.004060000000000000,
0.001810000000000000,0.002040000000000000,0.001990000000000000,
0.002120000000000000,0.001880000000000000,0.008350000000000000,
0.003550000000000000,0.009230000000000000,0.002020000000000000,
0.011809999999999999,0.002150000000000000,0.002220000000000000,
0.002170000000000000,0.002220000000000000,0.009259999999999999,
0.001850000000000000,0.010059999999999999,0.005620000000000000,
0.027380000000000002,0.003020000000000000,0.001830000000000000,
0.002220000000000000,0.013200000000000000,0.013129999999999999,
0.001930000000000000,0.002330000000000000,0.001780000000000000,
0.002180000000000000,0.009169999999999999,0.009410000000000000,
0.004050000000000000,0.001680000000000000,0.001930000000000000,
0.003390000000000000,0.003050000000000000,0.943869999999999987,
0.006420000000000000,0.033320000000000002,0.002280000000000000,
0.010140000000000000,0.009160000000000000,0.016150000000000001,
0.002620000000000000,0.006920000000000000,0.007080000000000000,
0.003550000000000000,0.018900000000000000,0.002580000000000000,
0.002410000000000000,0.001750000000000000,0.002970000000000000,
0.001730000000000000,0.004590000000000000,0.002100000000000000,
0.027510000000000000,0.004630000000000000,0.002920000000000000,
0.004540000000000000,0.003110000000000000,0.007810000000000000,
0.001830000000000000,0.003050000000000000,0.744199999999999973,
0.061870000000000001,0.021120000000000000,0.008080000000000000,
0.005510000000000000,0.723239999999999994,0.002420000000000000,
0.049439999999999998,0.012470000000000000,0.004250000000000000,
0.004070000000000000,0.002160000000000000,0.001960000000000000,
0.001750000000000000,0.002040000000000000,0.001680000000000000,
0.005090000000000000,0.002210000000000000,0.002810000000000000,
0.005320000000000000,0.060190000000000000
)
, tolerance = 1e-8)
})